$(function(){
	
	$('.main-right .jiuxian').mouseenter(function(){
		$(this).find('.myjiu').css({'transform':'rotate(180deg)','margin-left':'0px',
		'margin-top':'10px'});
		$(this).find('.jiuxiantop').css({'background':'#fff'});
		$(this).find('.mydropdown').show();
	});
	
	$('.main-right .jiuxian').mouseleave(function(){
		$(this).find('.myjiu').css({'transform':'rotate(0deg)','margin-left':'5px',
		'margin-top':'2px'});
		$(this).find('.jiuxiantop').css({'background':'#E2E2E2'});
		$(this).find('.mydropdown').hide();
	});
	/*全部商品部分*/
	$('.div3 li').mouseenter(function(){
		$(this).css({'background':'#EEEEEE'});
		$(this).find('span').css({'color':'#b61d1d'});
		$('.div3 li').not($(this)).css({'background':'#A9302A'});
		
		$(this).find('.right').show();
		$('.right').not($(this).find('.right')).hide();
	});
	
	
	$('.div3 li').mouseleave(function(){
		$(this).find('.right').hide();
		$(this).find('span').css({'color':'#ffffff'});
		$(this).css({'bachground':'#A9302A'});
	});
	
	/*幻灯片*/
	//第一步
	$('.paging').show();
	$('.paging a:first').addClass('active');
	
	var imageWidth = $('.window').width();
	var imageSun = $('.img_reel img').size();
	var imageReelWidth = imageReelWidth * imageSun;
	
	$('.img-reel').css({'width': imageReelWidth});
	
	//第二步
	rotate = function(end){
		if (end) {
			var triggerID = imageSun -1;
			var image_reelPosition = triggerID * imageReelWidth;
			
			$('.psging a').removeClass('active');
			$active.addClass('active');
			$('.img_reel').animate({
				left: -image_reelPosition
			},500,function(){
				$(this).css({'left':'0px'});
			});
		}else{
			var triggrID = $active.attr('rel') -1;
			var image_reelPosition = triggrID * imageWidth;
			
			$('.paging a').removeClass('active');
			$active.addClass('active');
			
			$('.img_reel').animate({
				left: -image_reelPosition				
		},500);
	  }
	};
	rotateSwitch = function(){
		piay = setInterval(function(){
			$active = $('.paging a.active').next();
			rel=$('.paging a.active').attr('rel');
			document.title=rel;
			if( rel==7){
				$active = $('.paging a:first');
				end=true;
			}else{
				end=false;
			}
			rotate(end);
		},2000);
	};
	rotateSwitch();
	//第三步
	$('.img_reel a').hover(function(){
		clearInterval(play);
	},function(){
		rotateSwitch();
	});
	
	//on click
	$('.paging a').click(function(){
		$active = $(this);
		clearInterval(play);
		rotate(false);
		rotateSwitch();
		return false;
	});
	
});